<?php

use yii\db\Migration;

class m171024_065809_alert_account_record extends Migration
{
    private function createDbs(){
        $dbs = [];
        $dbs_info =\Yii::$app->params['db'];
        foreach($dbs_info as $k=>$v){
            $dbs[$k] = \Yii::createObject($v);
        }
        return $dbs;
    }
    public function safeUp()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->addColumn('{{%account_record}}', 'pay_wxpay', $this->decimal(0) . ' default 0 comment \'微信支付\'');
            $this->addColumn('{{%account_record}}', 'pay_alipay', $this->decimal(0) . ' default 0 comment \'支付宝支付\'');
        }

    }

    public function safeDown()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->dropColumn('{{%account_record}}', 'pay_wxpay');
            $this->dropColumn('{{%account_record}}', 'pay_alipay');
        }
    }
}
